package num171;

/**
 * 171. Excel 表列序号
 * 题目：https://leetcode-cn.com/problems/excel-sheet-column-number/
 * 三叶姐题解: https://leetcode-cn.com/problems/excel-sheet-column-number/solution/gong-shui-san-xie-tong-yong-jin-zhi-zhua-y5fm/
 * 三叶姐
 */
class Solution {
    public int titleToNumber(String s) {
        char[] cs = s.toCharArray();
        int ans = 0;
        for (int i = 0; i < cs.length; i++) {
            ans = ans * 26 + (cs[i] - 'A' + 1);
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution().titleToNumber("A"));
    }
}
